package com.xuetang9.t9.hotel.controller;


import com.xuetang9.t9.hotel.beans.Guest;
import com.xuetang9.t9.hotel.mapper.condition.impl.GuestCondition;
import com.xuetang9.t9.hotel.services.IGuestService;
import com.xuetang9.t9.hotel.utils.OverallConstant;
import com.xuetang9.t9.hotel.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/guest")
@ResponseBody
public class GuestController {

    @Autowired
    private IGuestService guestService;

    /**
     * 检索全部客人信息
     * @return
     */
    @RequestMapping(value = "/all",method = RequestMethod.POST)
    private ResponseResult showByAll(@RequestBody GuestCondition condition){
        if(condition == null){
            condition = new GuestCondition();
        }
        return guestService.queryByAll(condition);
    }

    /**
     * 在住客人信息
     * @return
     */
    @RequestMapping(value = "/online",method = RequestMethod.POST)
    private ResponseResult showByOnline(@RequestBody GuestCondition condition){
        if (condition == null){
            condition = new GuestCondition();
        }
        condition.setState(OverallConstant.ARRIVE_ONLINE);
        return guestService.queryByAll(condition);
    }

    /**
     * 新增客人信息
     * @param guest
     * @return
     */
    @RequestMapping("/save")
    private ResponseResult save(@RequestBody Guest guest){
        if(guest == null){
            return null;
        }
        return guestService.save(guest);
    }

    /**
     * 更新客人信息
     * @param guest
     * @return
     */
    @RequestMapping("/update")
    private ResponseResult update(@RequestBody Guest guest){
        return null;
    }

    /**
     * 删除客人信息
     * @param id
     * @return
     */
    @RequestMapping("/remove")
    private ResponseResult remove(Long id){
        return null;
    }
}
